package me.xiaoxing365;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class MRDriver {
    public static void main(String[] args) throws Exception {
        //获取配置信息，封装任务
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf," ");
        //设置Jar包加载路径
        job.setJarByClass(MRDriver.class);
        //设置mapper和reducer
        job.setMapperClass(WordCountMapper.class);
        job.setReducerClass(Rreducer.class);
        //设置Mapper输出
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);
        //设置输入输出路径
        FileInputFormat.addInputPath(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));
        //提交任务
        // job.waitForCompletion(true);
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}